#region Using directives
using System;
using Microsoft.DirectX;
using SharpWind.Math;
using SharpWind.Resources.Shaders;
#endregion

namespace SharpWind.Scene
{
	public abstract class SceneObject
	{
		#region Fields

		protected Matrix translation = Matrix.Identity;

		protected Matrix rotation = Matrix.Identity;

		protected Matrix scale = Matrix.Identity;

		protected BoundingSphere boundingSphere = null;

		protected BoundingBox boundingBox = null;

		protected Shader shader = null;

		private float rotationX = 0f;

		private float rotationY = 0f;

		private float rotationZ = 0f;

		#endregion

		#region Methods

		internal virtual void Update( float elapsedTime )
		{

		}

		internal virtual void Render( Shader shader )
		{

		}

		#endregion

		#region Properties

		public float PositionX
		{
			get
			{
				return this.translation.M41;
			}
			set
			{
				this.translation.M41 = value;
			}
		}

		public float PositionY
		{
			get
			{
				return this.translation.M42;
			}
			set
			{
				this.translation.M42 = value;
			}
		}

		public float PositionZ
		{
			get
			{
				return this.translation.M43;
			}
			set
			{
				this.translation.M43 = value;
			}
		}

		public float RotationX
		{
			get
			{
				return this.rotationX;
			}
			set
			{
				this.rotationX = value;
				this.rotation = Matrix.RotationYawPitchRoll( this.rotationY, this.rotationX, this.rotationZ );
			}
		}

		public float RotationY
		{
			get
			{
				return this.rotationY;
			}
			set
			{
				this.rotationY = value;
				this.rotation = Matrix.RotationYawPitchRoll( this.rotationY, this.rotationX, this.rotationZ );
			}
		}

		public float RotationZ
		{
			get
			{
				return this.rotationZ;
			}
			set
			{
				this.rotationZ = value;
				this.rotation = Matrix.RotationYawPitchRoll( this.rotationY, this.rotationX, this.rotationZ );
			}
		}

		public float ScaleX
		{
			get
			{
				return this.scale.M11;
			}
			set
			{
				this.scale.M11 = value;
			}
		}

		public float ScaleY
		{
			get
			{
				return this.scale.M22;
			}
			set
			{
				this.scale.M22 = value;
			}
		}

		public float ScaleZ
		{
			get
			{
				return this.scale.M33;
			}
			set
			{
				this.scale.M33 = value;
			}
		}

		public Shader Shader
		{
			get
			{
				return this.shader;
			}
			set
			{
				this.shader = value;
			}
		}

		internal Matrix WorldMatrix
		{
			get
			{
				return this.scale * this.rotation * this.translation;
			}
		}

		internal BoundingBox BoundingBox
		{
			get
			{
				return this.boundingBox;
			}
		}

		internal BoundingSphere BoundingSphere
		{
			get
			{
				return this.boundingSphere;
			}
		}

		#endregion
	}
}